<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>

    function recursionBackTracking(nums) {
      // 输出数组
      let outArray = [];

      function recursion(index, selectNum) {
        // 向输出数组添加当前组合
        outArray.push(selectNum);
        // 从当前索引遍历继续递归，直到超出nums长度
        for (let i = index; i < nums.length; i++) {
          recursion(i + 1, [...selectNum, nums[i]]);
        }
      }
      // 执行递归
      recursion(0, []);
      // 返回结果
      return outArray;
    }
    console.log(recursionBackTracking(nums = [1, 2, 3]))
  </script>
</body>

</html>